import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import typescript from '@rollup/plugin-typescript'
import { resolve } from 'path'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    vueJsx(),
    typescript({
      tslib: require.resolve('typescript'),
      rootDir: resolve(__dirname, 'src/lib')
    })
  ],
  resolve: {
    alias: {
      '@': resolve(__dirname, 'src')
    }
  },
  build: {
    lib: {
      entry: resolve(__dirname, 'src/lib/index.ts'),
      name: 'SpsStore',
      fileName: 'index'
    },
    rollupOptions: {
      external: ['vue', 'reflect-metadata'],
      output: {
        globals: {
          vue: 'Vue'
        }
      }
    }
  }
})
